# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=xf86-video-voodoo
pkgver=1.2.5
pkgrel=11
pkgdesc="X.org 3dfx Voodoo1/Voodoo2 2D video driver"
arch=(x86_64)
url="https://xorg.freedesktop.org/"
license=('custom')
depends=('glibc')
makedepends=('xorg-server-devel' 'X-ABI-VIDEODRV_VERSION=24.0' 'xorgproto')
conflicts=('xorg-server<1.20' 'X-ABI-VIDEODRV_VERSION<24' 'X-ABI-VIDEODRV_VERSION>=25')
groups=('xorg-drivers')
source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2 git-fixes.diff)
sha256sums=('9e3eb8a3fdcc60ce4f7c37649188cfa67dcf25cda3a85d8027588458bb3fd7e8'
            'ab21fc45573bb309f3ad413a3242a48e0850b0fe36f30cad8443a2555cafcd66')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -Np1 -i ../git-fixes.diff
}

build() {
  cd ${pkgname}-${pkgver}

  # Since pacman 5.0.2-2, hardened flags are now enabled in makepkg.conf
  # With them, module fail to load with undefined symbol.
  # See https://bugs.archlinux.org/task/55102 / https://bugs.archlinux.org/task/54845
  export CFLAGS=${CFLAGS/-fno-plt}
  export CXXFLAGS=${CXXFLAGS/-fno-plt}
  export LDFLAGS=${LDFLAGS/,-z,now}

  ./configure --prefix=/usr
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
